package com.hjc.controller;

import com.hjc.entity.InStore;
import com.hjc.entity.Result;
import com.hjc.entity.Store;
import com.hjc.page.Page;
import com.hjc.service.InStoreService;
import com.hjc.service.StoreService;
import com.hjc.utils.TokenUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/instore")
public class InStoreController {
    @Autowired
    private InStoreService inStoreService;
    @Autowired
    private StoreService storeService;
    @Autowired
    private TokenUtils tokenUtils;


//    http://localhost:3000/api/instore/store-list?_t=1697534978406
//    http://localhost:3000/api/instore/instore-page-list?
//    storeId=1&productName=&startTime=&endTime=&pageSize=5&pageNum=1&totalNum=0
    @RequestMapping("/store-list")
    public Result findAllStore() {
        List<Store> allStore = storeService.findAllStore();
        return Result.ok(allStore);
    }

    @RequestMapping("/instore-page-list")
    public Result findInStoreByPage(InStore inStore, Page page) {
        page = inStoreService.findInStoreByPage(inStore, page);
        return Result.ok(page);
    }

//    http://localhost:3000/api/instore/instore-confirm
    @RequestMapping("/instore-confirm")
    public Result confirmInStore(@RequestBody InStore inStore) {
        return inStoreService.confirmInStore(inStore);
    }


}
